from PyQt5.QtCore import pyqtSlot, QTimer, Qt
from PyQt5.QtGui import QImage, QPixmap, QPalette, QIntValidator

from ui.Ui_MianWindow import Ui_MainWindow
from openni import openni2
from tools import *
from collections import namedtuple

import numpy as np
import cv2
import mediapipe as mp
import time

from ui.Ui_SavePersonDialog import Ui_SaveInfoDialog


class savePersonInfo(QtWidgets.QDialog):
    def __init__(self):
        QtWidgets.QDialog.__init__(self)
        self.ui = Ui_SaveInfoDialog()
        self.ui.setupUi(self)
        self.ui.lineEdit.setFocus()
        self.name = ""
        self.height = ""
        self.weight = ""

        self.ui.lineEdit_2.setValidator(QIntValidator(1, 500))
        self.ui.lineEdit_3.setValidator(QIntValidator(1, 1000))
        self.ui.pushButton.clicked.connect(self.saveClicked)

    @pyqtSlot()
    def saveClicked(self):
        # alert("保存成功","消息",QtWidgets.QMessageBox.Information)
        self.name = self.ui.lineEdit.text()
        self.height = self.ui.lineEdit_2.text()
        self.weight = self.ui.lineEdit_3.text()
        if self.name != "" and self.height != "" and self.weight != "":
            self.accept()
        else:
            alert("\n都必须填写后，才能保存\n")
